#include "stdio.h"
#include <malloc.h>
#include <stdlib.h>
//对的

typedef struct Char_Link
{
    char text;
    struct Char_Link* next;
}Char_Link,*Char_Link_Ptr;


typedef struct 
{
    Char_Link_Ptr top;
    Char_Link_Ptr base;
}Stackle_For_Char,*Stackle_For_Char_Ptr;


Stackle_For_Char_Ptr Stackle_For_Char_Init()
{
    Stackle_For_Char_Ptr head = (Stackle_For_Char_Ptr)malloc(sizeof(Stackle_For_Char));
    if(!head)   exit(1);
    head->top = NULL;
    head->base = NULL;
    return head;
}


void Stackle_For_Char_Push(Stackle_For_Char_Ptr Stack,char word)
{
    if(Stack->base == NULL)
    {
        Stack->top = (Char_Link_Ptr)malloc(sizeof(Char_Link));
        Stack->base = Stack->top;
        Stack->top->next = NULL;
        Stack->top->text = word;
    }
    else
    {
        Char_Link_Ptr temp;
        temp = Stack->top;
        Stack->top = (Char_Link_Ptr)malloc(sizeof(Char_Link));
        temp->next = Stack->top;
        Stack->top->text = word;
        Stack->top->next = NULL;
    }
}


void Stackle_For_Char_Pop(Stackle_For_Char_Ptr Stack)
{
    if(Stack->base == NULL)  exit(1);
    if(Stack->base != NULL)
    {
        if(Stack->base == Stack->top)
        {
            free(Stack->base);
            Stack->base = NULL;
            Stack->top = NULL;
        }
        else
        {
            Char_Link* temp;
            temp = Stack->base;
            for(;temp->next != Stack->top;)    temp = temp->next;
            free(Stack->top);
            Stack->top = temp;
            Stack->top->next = NULL;
        }

    }
}

void Print_Stack_For_Char(Stackle_For_Char_Ptr Stack)
{
    Char_Link* cur = Stack->base;
    for(;cur->next!=NULL;cur = cur->next)
    {
        printf("%c",cur->text);
    }
    printf("%c",cur->text);
}
/*
void main()
{
    Stackle_For_Char_Ptr Stack_For_Char;
    Stack_For_Char = Stackle_For_Char_Init();
    Stackle_For_Char_Push(Stack_For_Char,'a');
    Stackle_For_Char_Push(Stack_For_Char,'b');
    Stackle_For_Char_Push(Stack_For_Char,'c');
    Stackle_For_Char_Push(Stack_For_Char,'d');
    Stackle_For_Char_Pop(Stack_For_Char);
    Print_Stack_For_Char(Stack_For_Char);
}
*/